package com.sywl.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;


public class AuthenticationInterceptor implements HandlerInterceptor {

	public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
			Object handler) throws Exception {
		System.out.println("Pre-handle");
		/*String uri=request.getRequestURI();
		if(!uri.endsWith("login.do")&&!uri.endsWith("logout.do")){
			User userData=(User)request.getSession().getAttribute("LOGGEDIN_USER");
			if(userData==null){
				response.sendRedirect(request.getContextPath()+"/index.jsp");
				return false;
			}
		}*/
		return true;
	}
	
	public void postHandle(HttpServletRequest request, HttpServletResponse response,
			Object handler, ModelAndView modelAndView) throws Exception {
		System.out.println("Post-handle");
	}

	
	public void afterCompletion(HttpServletRequest req,
			HttpServletResponse resp, Object obj, Exception e)
			throws Exception {
		System.out.println("After completion handle");
	}
}
